package com.momo.common.req.sysSetting.authority;

import com.momo.common.error.BaseReq;
import com.momo.mapper.dataobject.AclModuleDO;
import lombok.*;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * Created by Kagome on 2019/3/19.
 */
@Getter
@Setter
@ToString
@Builder
@NoArgsConstructor
@AllArgsConstructor
//@EqualsAndHashCode(of = {"id"})
public class AclModuleReq extends BaseReq {
    /**
     * id 权限模块id.
     */
    private Long id;
    /**
     * sysAclModuleParentId 上级权限模块id.
     */
    @NotNull(message = "上级权限模块id 必填", groups = {Add.class, Modify.class})
    private Long sysAclModuleParentId;
    /**
     * sysAclPermissionType 菜单系统类型 1 系统管理 2资产管理.
     */
    @NotNull(message = "菜单系统类型 必填", groups = {Add.class})
    @Min(value = 1)
    private Long sysAclPermissionType;
    /**
     * delFlag 删除状态(0-正常，1-删除).
     */
    private String delFlag = "0";
    /**
     * createBy 创建人.
     */
    private String createBy;
    /**
     * updateBy 修改人.
     */
    private String updateBy;
    /**
     * sysAclModuleCode 权限模块码.
     */
    private String sysAclModuleCode;
    /**
     * sysAclModuleIcon 图标class.
     */
    private String sysAclModuleIcon;
    /**
     * sysAclModuleName 权限模块名称.
     */
    @NotBlank(message = "权限模块名称 必填", groups = {Add.class, Modify.class})
    private String sysAclModuleName;
    /**
     * sysAclModuleUuid 唯一，32位字符串，查询用.
     */
    @NotBlank(message = "uuid 必填", groups = {Modify.class,Status.class,Detail.class})
    private String sysAclModuleUuid;
    /**
     * sysAclModuleLevel 权限模块层级.
     */
    private String sysAclModuleLevel;
    /**
     * sysAclModuleRemark 备注.
     */
    private String sysAclModuleRemark;
    /**
     * sysAclModuleSeq 权限模块在当前层级下的顺序，由小到大.
     */
    @NotNull(message = "权限模块在当前层级下的顺序，由小到大 必填", groups = {Add.class, Modify.class})
    private Integer sysAclModuleSeq;
    /**
     * sysAcModulelStatus 状态 0启用  1禁用.
     */
    @NotBlank(message = "状态 0启用  1禁用. 必填", groups = {Add.class, Modify.class,Status.class})
    private String sysAcModulelStatus;

    public static AclModuleReqRedis aclModuleRedis(AclModuleDO aclModuleDO) {
        AclModuleReqRedis aclModuleReqTwo = AclModuleReq.AclModuleReqRedis.builder().sysAclModuleLevel(aclModuleDO.getSysAclModuleLevel())
                .sysAclModuleName(aclModuleDO.getSysAclModuleName()).sysAclModuleParentId(aclModuleDO.getSysAclModuleParentId())
                .sysAclModuleSeq(aclModuleDO.getSysAclModuleSeq()).sysAclPermissionType(aclModuleDO.getSysAclPermissionType())
                .id(aclModuleDO.getId()).sysAcModulelStatus(aclModuleDO.getSysAcModulelStatus()).build();
        return aclModuleReqTwo;
    }
    @Getter
    @Setter
    @ToString
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class AclModuleReqRedis {
        /**
         * id 权限模块id.
         */
        private Long id;
        /**
         * sysAclModuleParentId 上级权限模块id.
         */
        private Long sysAclModuleParentId;
        /**
         * sysAclPermissionType 菜单系统类型 1 系统管理 2资产管理.
         */
        private Long sysAclPermissionType;

        /**
         * sysAclModuleCode 权限模块码.
         */
        private String sysAclModuleCode;
        /**
         * sysAclModuleIcon 图标class.
         */
        private String sysAclModuleIcon;
        /**
         * sysAclModuleName 权限模块名称.
         */
        private String sysAclModuleName;
        /**
         * sysAclModuleLevel 权限模块层级.
         */
        private String sysAclModuleLevel;
        /**
         * sysAclModuleSeq 权限模块在当前层级下的顺序，由小到大.
         */
        private Integer sysAclModuleSeq;
        /**
         * sysAcModulelStatus 状态 0启用  1禁用.
         */
        private String sysAcModulelStatus;
    }
}
